//
//  ViewController.m
//  FMDBDemo
//
//  Created by YY on 16/10/16.
//  Copyright © 2016年 CheDan. All rights reserved.
//

#import "ViewController.h"

#import "FMDBManager.h"
#import "F.h"
#import "Member.h"
#import "Score.h"


@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
//    [[FMDBManager shareManager] createTable];
//    
//    [self insertDBData];
    
    NSLog(@"%@",[[FMDBManager shareManager] dbPath]);
    
    [self neilian];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)insertDBData{
    
    NSArray *memberA = @[@{@"MID":@"1001",@"MName":@"张撒"},
                        @{@"MID":@"1002",@"MName":@"王强"},
                        @{@"MID":@"1003",@"MName":@"李三"},
                        @{@"MID":@"1004",@"MName":@"李四"}];
    
    
    NSArray *FA =      @[@{@"FID":@"2001",@"FName":@"语文"},
                        @{@"FID":@"2002",@"FName":@"数学"},
                        @{@"FID":@"2003",@"FName":@"英语"},
                        @{@"FID":@"2004",@"FName":@"历史"}];
    

    NSArray *ScoreA = @[@{@"SID":@"1",@"FID":@"2001",@"MID":@"1001",@"Score":@"78",
                       @"SID":@"1",@"FID":@"2002",@"MID":@"1001",@"Score":@"67",
                       @"SID":@"1",@"FID":@"2003",@"MID":@"1001",@"Score":@"89",
                       @"SID":@"1",@"FID":@"2004",@"MID":@"1001",@"Score":@"76"},
                       @{@"SID":@"2",@"FID":@"2001",@"MID":@"1002",@"Score":@"89",
                         @"SID":@"2",@"FID":@"2002",@"MID":@"1002",@"Score":@"67",
                         @"SID":@"2",@"FID":@"2003",@"MID":@"1002",@"Score":@"84",
                         @"SID":@"2",@"FID":@"2004",@"MID":@"1002",@"Score":@"96"},
                       @{@"SID":@"3",@"FID":@"2001",@"MID":@"1003",@"Score":@"70",
                         @"SID":@"3",@"FID":@"2002",@"MID":@"1003",@"Score":@"87",
                         @"SID":@"3",@"FID":@"2003",@"MID":@"1003",@"Score":@"92",
                         @"SID":@"3",@"FID":@"2004",@"MID":@"1003",@"Score":@"56"},
                       @{@"SID":@"4",@"FID":@"2001",@"MID":@"1004",@"Score":@"80",
                         @"SID":@"4",@"FID":@"2002",@"MID":@"1004",@"Score":@"78",
                         @"SID":@"4",@"FID":@"2003",@"MID":@"1004",@"Score":@"97",
                         @"SID":@"4",@"FID":@"2004",@"MID":@"1004",@"Score":@"66"},];
    
    
    for (NSDictionary *dict in memberA) {
        Member *mem = [Member new];
        [mem setValuesForKeysWithDictionary:dict];
        [[FMDBManager shareManager] inserMember:mem];
    }

    for (NSDictionary *dict in FA) {
        F *mem = [F new];
        [mem setValuesForKeysWithDictionary:dict];
        [[FMDBManager shareManager] inserF:mem];
    }
    for (NSDictionary *dict in ScoreA) {
        Score *mem = [Score new];
        [mem setValuesForKeysWithDictionary:dict];
        [[FMDBManager shareManager] inserScore:mem];
    }
}

- (void)neilian{
    for (Member *member in [[FMDBManager shareManager] executeNeiLianSql]) {
        NSLog(@"member name %@",member.MName);
    }

}

@end
